<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns:MSHelp="http://www.microsoft.com/MSHelp/" lang="en-us" xml:lang="en-us"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<meta name="DC.Type" content="reference">
<meta name="DC.Title" content="tbb::serial::parallel_for()">
<meta name="DC.subject" content="tbb::serial::parallel_for()">
<meta name="keywords" content="tbb::serial::parallel_for()">
<meta name="DC.Relation" scheme="URI" content="../../../../reference/appendices/community_preview_features/serial_subset.htm">
<meta name="DC.Format" content="XHTML">
<meta name="DC.Identifier" content="tbb_serial_parallel_for">
<meta name="DC.Language" content="en-US">
<link rel="stylesheet" type="text/css" href="../../../../intel_css_styles.css">
<title>tbb::serial::parallel_for()</title>
<xml>
<MSHelp:Attr Name="DocSet" Value="Intel"></MSHelp:Attr>
<MSHelp:Attr Name="Locale" Value="kbEnglish"></MSHelp:Attr>
<MSHelp:Attr Name="TopicType" Value="kbReference"></MSHelp:Attr>
</xml>
</head>
<body id="tbb_serial_parallel_for">
 <!-- ==============(Start:NavScript)================= -->
 <script src="..\..\..\..\NavScript.js" language="JavaScript1.2" type="text/javascript"></script>
 <script language="JavaScript1.2" type="text/javascript">WriteNavLink(4);</script>
 <!-- ==============(End:NavScript)================= -->
<a name="tbb_serial_parallel_for"><!-- --></a>


  <h1 class="topictitle1">tbb::serial::parallel_for()</h1>

  
  <div>
	 <div class="section"><h2 class="sectiontitle">Header</h2>
		
		<p>#define TBB_PREVIEW_SERIAL_SUBSET 1
		</p>

		<p>#include "tbb/ parallel_for.h"
		</p>

	 </div>

	 <div class="section"><h2 class="sectiontitle">Motivation</h2>
		
		<p>Sometimes it is useful, for example while
		  debugging, to execute certain 
		  <samp class="codeph">parallel_for()</samp>
		  invocations serially while having other invocations of 
		  <samp class="codeph">parallel_for()</samp>executed
		  in parallel.
		</p>

	 </div>

	 <div class="section"><h2 class="sectiontitle">Description</h2>
		
		<p>The 
		  <samp class="codeph">tbb::serial::parallel_for</samp> function
		  implements the 
		  <samp class="codeph">tbb::parallel_for</samp> API
		  using a serial implementation underneath. Users who want sequential execution
		  of a certain 
		  <samp class="codeph">parallel_for()</samp>
		  invocation will need to define the 
		  <samp class="codeph">TBB_PREVIEW_SERIAL_SUBSET</samp> macro before
		  parallel_for.h and prefix the selected 
		  <samp class="codeph">parallel_for()</samp> with 
		  <samp class="codeph">tbb::serial::</samp>.
		  Internally, the serial implementation uses the same principle of recursive
		  decomposition, but instead of spawning tasks, it does recursion "for real",
		  i.e. the body function calls itself twice with two halves of its original
		  range.
		</p>

	 </div>

	 <div class="section"><h2 class="sectiontitle">Example</h2>
		
		<pre>#define TBB_PREVIEW_SERIAL_SUBSET 1
#include &lt;tbb/parallel_for.h&gt;
#include &lt;tbb/parallel_for.h&gt;
#include &lt;tbb/parallel_for.h&gt;
Foo()
{
  // . . .
  tbb::serial::parallel_for( . . . );
  tbb::parallel_for( . . . );
  // . . . 
}</pre>
	 </div>

  </div>


<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong>&nbsp;<a href="../../../../reference/appendices/community_preview_features/serial_subset.htm">Serial subset</a></div>
</div>
<div></div>

</body>
</html>
